package ducna.android.aoeclip.common.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * Created by DUCNA on 11/4/2014.
 */
public class NetworkHelper {

    public static boolean hasNetworkConnection(Context context) {
        ConnectivityManager connectivity = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (connectivity == null) {
            return false;// <-- -- -- NOT Connected
        } else {
            NetworkInfo[] info = connectivity.getAllNetworkInfo();
            if (info != null) {
                for (int i = 0; i < info.length; i++) {
                    if (info[i].getState() == NetworkInfo.State.CONNECTED) {
                        return true; // <-- -- -- Connected
                    }
                }
            }
        }
        return false; // <-- -- -- NOT Connected
    }
}
